<?php
/**
 * @deprecated
 */
class Workset_Model_Iterator_KeyValue implements OuterIterator  {

    protected $_keyIndex = null;

    protected $_valueIndex = null;

    protected $_iterator = null;

    function __construct(Iterator $innerIterator, $key = null, $value = null) {
        $this->_iterator = $innerIterator;
        if (null !== $key) {
            $this->setKeyIndex($key);
        }
        if (null !== $value) {
            $this->setValueIndex($value);
        }
    }

    function setKeyIndex($key) {
        $this->_keyIndex = $key;
        return $this;
    }

    function setValueIndex($key) {
        $this->_valueIndex = $key;
        return $this;
    }

    function getInnerIterator() {
        return $this->_iterator;
    }

    function current() {
        if ($this->_iterator->valid() === false) {
            return null;
        }
        $data = $this->_iterator->current();
        return isset($data[$this->_valueIndex]) ? $data[$this->_valueIndex] : null;
    }

    function key() {
        $data = $this->_iterator->current();
        return isset($data[$this->_keyIndex]) ? $data[$this->_keyIndex] : null;
    }

    function next() {
        $this->_iterator->next();
    }

    function valid() {
        return $this->_iterator->valid();
    }

    function rewind() {
        $this->_iterator->rewind();
        return $this;
    }

    function toArray() {
        $result = array();
        foreach ($this as $key => $value) {
            $result[$key] = $value;
        }
        return $result;
    }

}

?>